package com.lanyou.cook.entitylistener.domain;

import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;

import com.lanyou.cook.datadictionary.UserLogOpt;
import com.lanyou.cook.entity.domain.DBlinkDataSource;
import com.lanyou.cook.service.UserLogService;

public class DBlinkDataSourceEntityListenerForLog {

	@PrePersist
	public void prePersist(DBlinkDataSource target) {
		String content = String.format("新增DBlink数据库链接“%s”", target.getName());
		UserLogService.getInstance().save(UserLogOpt.MaintenanceDataSource, null, content);
	}
	
	@PreUpdate
	public void preUpdate(DBlinkDataSource target) {
		String content = String.format("修改DBlink数据库链接“%s”", target.getName());
		UserLogService.getInstance().save(UserLogOpt.MaintenanceDataSource, null, content);
	}
	
	@PreRemove
	public void preRemove(DBlinkDataSource target) {
		String content = String.format("删除DBlink数据库链接“%s”", target.getName());
		UserLogService.getInstance().save(UserLogOpt.MaintenanceDataSource, null, content);
	}
	
}
